﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ionic.Zip;

namespace FW
{
    public class zip
    {

        public zip()
        { 
        
        }

        public void zipDir(string output, string diretorio)
        {
            try
            {
                using (ZipFile zipf = new ZipFile())
                {
                    zipf.StatusMessageTextWriter = System.Console.Out;
                    zipf.AddDirectory(diretorio); // recurses subdirectories
                    zipf.UseZip64WhenSaving = Zip64Option.AsNecessary;
                    zipf.Save(output);
                }
                
            }
            catch (System.Exception ex1)
            {
                throw (ex1);
            }

        }

        public void zipArq(string output, string arquivo, string diret)
        {
            try
            {
                using (ZipFile zipf = new ZipFile())
                {
                    zipf.StatusMessageTextWriter = System.Console.Out;
                    zipf.AddFile(arquivo, diret);
                    //zipf.AddDirectory(diretorio); // recurses subdirectories
                    zipf.Save(output);
                }

            }
            catch (System.Exception ex1)
            {
                throw (ex1);
            }

        }

        public void zipArq(string output, string arquivo)
        {
            try
            {
                using (ZipFile zipf = new ZipFile())
                {
                    zipf.StatusMessageTextWriter = System.Console.Out;
                    zipf.AddFile(arquivo);
                    //zipf.AddDirectory(diretorio); // recurses subdirectories
                    zipf.Save(output);
                }

            }
            catch (System.Exception ex1)
            {
                throw (ex1);
            }

        }

        public void addFile(string output, string file)
        {
            ZipFile zipf = new ZipFile();
            
            zipf.AddFile(file, "/");
            zipf.Save(output);
        }

    }
}
